/**
 * 
 */
package com.gopay.bis.dao.payconfig.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.bis.dao.payconfig.LogSMSSendDAO;
import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.domain.log.LogSMSSend;
import com.gopay.common.util.DateUtils;

/**
 * 短信日志DAO
 * 
 * @LogSMSSendDAOImpl.java
 * @author xiefei
 * @2013-5-8 下午12:02:19 www.gopay.com.cn Inc.All rights reserved.
 */
@Repository("logSMSSendDAO")
public class LogSMSSendDAOImpl extends BaseDAOImpl<LogSMSSend, Integer> implements LogSMSSendDAO {

	@Override
	public int findToDayCountByMobileNum(String mobNum, String mobileID) {
		String hql = "SELECT COUNT(*) FROM LogSMSSend S WHERE S.mobileNum=:mobileNum AND S.mobileID=:mobileID AND S.sendTime >= to_timestamp(:sendTime,'yyyy-MM-dd')";
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("mobileNum", mobNum);
		param.put("mobileID", mobileID);
		param.put("sendTime", DateUtils.format(new Date(), "yyyy-MM-dd"));
		return this.findCountByHql(hql, param);
	}

	@Override
	public int findToDayCountByRemark(String remarks, String mobileID) {
		String hql = "SELECT COUNT(*) FROM LogSMSSend S WHERE S.remarks=:remarks AND S.mobileID=:mobileID AND S.sendTime >= to_timestamp(:sendTime,'yyyy-MM-dd')";
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("remarks", remarks);
		param.put("mobileID", mobileID);
		param.put("sendTime", DateUtils.format(new Date(), "yyyy-MM-dd"));
		return this.findCountByHql(hql, param);
	}

}
